/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.myapp.struts.Exercise.ReportExercise;

import com.myapp.model.ejercicios.Ejercicios;
import com.myapp.model.usuarios.Usuarios;
import com.myapp.svc.Exercise.ExerciseSvc;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author Tarde
 */
public class ReportarEjercicioAction extends org.apache.struts.action.Action {

    /* forward name="success" path="" */
    private static final String SUCCESS = "success";

   @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
       ExerciseSvc ejerSvc=new ExerciseSvc();
       Usuarios usr=new Usuarios();
       Ejercicios ejer=new Ejercicios();
       HttpSession session=request.getSession();
       usr=(Usuarios) session.getAttribute("usuarios");
       String idEjercicio=request.getParameter("idEjercicio");
       ejer=ejerSvc.listarPorId(idEjercicio);
       ejerSvc.reportar(ejer,usr);
        return mapping.findForward(SUCCESS);
    }
}
